package apoc.core.command;

import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;

import java.util.Arrays;
import java.util.HashMap;

public class CommandApoc extends CommandBase
{

    private static HashMap<String, IPluginCommand> commands = new HashMap<String, IPluginCommand>();

    public static void addCommand(IPluginCommand command)
    {
        commands.put(command.getName(), command);
    }

    @Override
    public String getCommandName()
    {
        return "apoc";
    }

    @Override
    public String getCommandUsage(ICommandSender var1)
    {
        return "/apoc [option]";
    }

    @Override
    public void processCommand(ICommandSender sender, String[] args)
    {
        if (args.length > 0)
        {
            IPluginCommand command = commands.get(args[0]);
            if (command != null)
                command.process(sender, Arrays.copyOfRange(args, 1, args.length));
        }
    }

    public int compareTo(ICommand par1ICommand)
    {
        return this.getCommandName().compareTo(par1ICommand.getCommandName());
    }

    public int compareTo(Object par1Obj)
    {
        return this.compareTo((ICommand) par1Obj);
    }
}
